<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>菜品管理-订餐管理系统</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../static/css/font.css">
		<link rel="stylesheet" href="../../static/css/weadmin.css">
		<script src="../../lib/layui/layui.js" charset="utf-8"></script>
		<!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
		<!--[if lt IE 9]>
	      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
	      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
	    <![endif]-->
	</head>

	<body>
		<div class="weadmin-nav">
			<span class="layui-breadcrumb">
        <a href="">首页</a>
        <a><cite>菜品管理</cite></a>
      </span>
			<a class="layui-btn layui-btn-sm" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
				<i class="layui-icon" style="line-height:30px">ဂ</i></a>
		</div>
		<div class="weadmin-body">
			<div class="layui-form">
				<div class="layui-row layui-form-item" style="width: 10%">
					<select name="cuisine" lay-filter="cuisine">
						<option value="">菜系</option>
						<option value="010">川菜</option>
						<option value="021">徽菜</option>
						<option value="0571">粤菜</option>
					</select>
				</div>
			</div>
			<div class="weadmin-block">
				<button class="layui-btn" onclick="WeAdminShow('添加菜品','./add.html')"><i class="layui-icon"></i>添加</button>
			</div>
			<table class="layui-table">
				<thead>
					<tr>
						<th>
							<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
						</th>
						<th>菜品编号</th>
						<th>菜品名</th>
						<th>图片</th>
						<th>所属菜系</th>
						<th>价格</th>
						<th>会员价格</th>
						<th>操作</th>
					</tr>
				</thead>
				<tbody id="dishList">
					<tr>
						<td>
							<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
						</td>
						<td>2017009171822298053</td>
						<td><img src="../../static/images/dish/4ec2d5628535e5dd78a777e174c6a7efce1b6201.jpg"></td>
						<td>7829.10</td>
						<td>7854.10</td>
						<td>待确认</td>
						<td class="td-manage">
							<a title="编辑" onclick="WeAdminShow('编辑','order-view.html')" href="javascript:;">
								<i class="layui-icon">&#xe63c;</i>
							</a>
							<a title="删除" onclick="member_del(this,'要删除的id')" href="javascript:;">
								<i class="layui-icon">&#xe640;</i>
							</a>
						</td>
					</tr>
				</tbody>
			</table>
			<div class="page">
				<div>
					<a class="prev" href="">&lt;&lt;</a>
					<a class="num" href="">1</a>
					<span class="current">2</span>
					<a class="num" href="">3</a>
					<a class="num" href="">489</a>
					<a class="next" href="">&gt;&gt;</a>
				</div>
			</div>

		</div>
		<script src="../../static/js/jquery.js"></script>
		<script src="../../static/js/setAjax.js"></script>
		<script>
			layui.extend({
				admin: '{/}../../static/js/admin'
			});
			layui.use(['laydate','jquery','admin','form'], function() {
				var laydate = layui.laydate,
						admin = layui.admin,
						form = layui.form;
				var layer = layui.layer;
				$.ajax({
					url:'/dish',
					type:'get',
					dataType:'json',
					success:function (data) {
						if(data.state=="success"){
							var _html = '';
							for (var i=0;i<data.dishList.length;i++){
								console.log(i)
								_html +=`<tr>
<td>
<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>
</td>
<td>${i+1}</td>
<td>${data.dishList[i].dishName}</td>
<td><img src="../../static/images/dish/${data.dishList[i].dishImg}.jpg"></td>
<td>${data.dishList[i].dishCuisine}</td>
<td>${data.dishList[i].dishPrice}</td>
<td>${data.dishList[i].dishMemberPrice}</td>
<td class="td-manage">
<a title="编辑" onclick="WeAdminShow('编辑','order-view.html')" href="javascript:;">
<i class="layui-icon">&#xe63c;</i>
</a>
<a title="删除" onclick="member_del(this,${data.dishList[i].dishId})" href="javascript:;">
<i class="layui-icon">&#xe640;</i>
</a>
</td>
</tr>`
							}
							$("#dishList").html(_html);
							layer.msg(data.message,{icon:1,time:2000});
						}else {
							layer.msg(data.message,{icon:2,time:2000})
						}
					},
					error:function(e) {
						console.log(e.responseText);
					}
				});
				form.render('select');
				form.on('select(cuisine)', function(data){
					console.log(data.elem); //得到select原始DOM对象
					console.log(data.value); //得到被选中的值
					console.log(data.othis); //得到美化后的DOM对象
				});


				/*用户-删除*/
				function member_del(obj, id) {
					layer.confirm('确认要删除吗？', function (index) {
						//发异步删除数据
						$(obj).parents("tr").remove();
						layer.msg('已删除!', {
							icon: 1,
							time: 1000
						});
					});
				}

			});
		</script>
	</body>

</html>